//    Copyright (C) Kherty.  All rights reserved.
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Globalization;
using System.Windows.Data;

namespace OpenLS.Chart.UI.Internals
{
    class ThrottlingConverter<T>: IMultiValueConverter
    {
        public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
        {
            var v = new List<T>((IEnumerable<T>) values[0]);
            int max = System.Convert.ToInt32(values[1]);
            if (values.Length > 2)
                max = Math.Max(max, System.Convert.ToInt32(values[2]));
            max = Math.Max(max, 100);
            var moduloCollection = new ModuloCollection<T>(v, Math.Max(v.Count / max, 1));
            return moduloCollection;
            return new OpenLS.Chart.UI.ProgressiveCollection<T>(moduloCollection, max);
        }

        public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture)
        {
            throw new NotSupportedException();
        }
    }
}